home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 43.zip
/
Sources C- WorkDisk V.adf
/
iff
/
plop.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-02-15
|
4KB
|
166 lines
#include <exec/types.h>
#include <exec/nodes.h>
#include <exec/libraries.h>
#include <graphics/gfx.h>
#include <graphics/rastport.h>
#include <graphics/text.h>
#include <intuition/intuition.h>
#include <stdio.h>
#include "df1:iff/jiff.c"
/*This should be in exec/libraries.h */
extern struct Library *OpenLibrary();
/*This should be in intuition/intuition.h */
extern struct Screen *OpenScreen();
/* These are the bases for the libraries you need to do any graphics
much at all and still multi-task */
struct Library *GfxBase = NULL;
struct Library *LayersBase = NULL;
struct Library *IntuitionBase = NULL;
/* Well the workbench Screen isn't 320x200x5 so...*/
struct Screen *PlopScreen = NULL;
/* Just one font for me... not static cause you might want it
in your menu modules. */
struct TextAttr PlopFont =
{
"topaz.font", /* I think this is the ROM font */
8,
0,
0,
};
/* a NewScreen - I don't know what half of this means either */
static
struct NewScreen PlopNewScreen =
{
0, 0, XMAX, YMAX, PLANES,
0, 1,
0,
CUSTOMSCREEN,
&PlopFont,
"Plop on Top",
NULL,
NULL,
};
/* To use clip blit need a RastPort. Pretty useless, a BitMap should
be enough I think ... or anyway something a little less massive */
struct RastPort PlopRastPort;
void
put_ea_cmap(cmap, colors)
unsigned char *cmap;
long colors;
{
long i;
unsigned long r, g, b;
if (colors > 32) /*color clipping*/
colors = 32;
/* This loop is modified to work with Aztec 3.4a 32bit by J. Van Houtven */
/* Modification Date : 20 July 1987 */
for (i=0; i<colors; i++)
{
r= *cmap++ >> 4;
g= *cmap++ >> 4;
b= *cmap++ >> 4;
SetRGB4(&PlopScreen->ViewPort,i,(long)r,(long)g,(long)b);
}
}
/* back out backwards */
void
plop_cleanup()
{
if (PlopScreen != NULL)
CloseScreen(PlopScreen);
if (IntuitionBase != NULL)
CloseLibrary(IntuitionBase);
if (LayersBase != NULL)
CloseLibrary(LayersBase);
if (GfxBase != NULL)
CloseLibrary(GfxBase);
}
main(argc, argv)
int argc;
char *argv[];
{
int i;
struct ILBM_info *info;
/*Before we can do ANYTHING have to get our libraries... */
if ((GfxBase = OpenLibrary("graphics.library", (long)0)) == NULL)
{
#ifdef PARANOID
printf("Can't open Graphics Library\n");
#endif PARANOID
return(-1);
}
if ((LayersBase = OpenLibrary("layers.library", (long)0)) == NULL)
{
#ifdef PARANOID
printf("Can't open Layers Library\n");
#endif PARANOID
plop_cleanup();
return(-2);
}
/* Two for Dale and one for RJ */
if ((IntuitionBase = OpenLibrary("intuition.library",(long) 0)) == NULL)
{
#ifdef PARANOID
printf("Can't open Intuition Library\n");
#endif PARANOID
plop_cleanup();
return(-3);
}
if ( (PlopScreen = OpenScreen(&PlopNewScreen) ) == NULL)
{
#ifdef PARANOID
printf("OpenScreen failed\n");
#endif PARANOID
plop_cleanup();
return(-4);
}
InitRastPort(&PlopRastPort);
/* PlopRastPort.Mask = (1<<PLANES)-1; */
/*just play it safe in case someone tries to load 6 bit planes...*/
for (i=1; i<argc; i++)
{
#ifdef DEBUG
puts(argv[i]);
#endif DEBUG
if ( (info = read_iff(argv[i], 0) ) != NULL)
{
put_ea_cmap(&info->cmap, (1 << info->bitmap.Depth));
PlopRastPort.BitMap = &info->bitmap;
ClipBlit( &PlopRastPort, (long)0, (long)0,
&PlopScreen->RastPort, (long)info->header.x, (long)info->header.y,
(long)info->header.w, (long)info->header.h, (long)COPY_MINTERM);
Delay( (long)250); /*pause for a couple seconds */
free_planes(&info->bitmap);
}
#ifdef PARANOID
else
printf("couldn't load %s as an IFF file\n");
#endif PARANOID
}
plop_cleanup();
}